<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 新 21 点 -->
    <script>
      var new21Game = function (N, K, W) {
        let dp = new Array(K + W)
        let sum = 0
        for (let i = K; i < K + W; i++) {
          dp[i] = i <= N ? 1 : 0
          sum += dp[i]
        }
        for (let i = K - 1; i >= 0; i--) {
          dp[i] = sum / W
          sum = sum - dp[i + W] + dp[i]
        }
        return dp[0]
      }
      console.log(new21Game(10, 1, 10))
    </script>
  </body>
</html>
